package com.example.demo.ioc;


import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Controller("AController")
public class A {

    @Autowired
    private E b;

    @Resource(name = "CController")
    private E c;

    @Autowired
    @Qualifier("DConfig")
    private D d;

    @Override
    public String toString() {
        return b + "-"  + c + "-" + d;
    }
}

@Service
class  B extends E {

}

@Repository("CController")
class C extends E {

}

@Configuration("DConfig")
class D {

    @Bean
    public LocalDateTime xxxxx(B b){
        System.out.println("xxxx" + b);
        return LocalDateTime.now();
    }
}

class  E {

}